namespace Test
import Grawlix

struct A:
	
	public val as double
	
	[Comparison]
	private def Comparison(rhs as A):
		return val - rhs.val

	[Comparison(InvertOperators: true)]
	private def Comparison(rhs as Compare):
		return val - rhs.val

final class Compare:
	public val = 0.0


a = A()
a.val = 0.0
b as System.IComparable = a
c as System.IComparable[of A] = a
d as object = a
e as Compare = Compare()
# F is unused
#f as object = e
w as Compare = null
x as System.IComparable = null
y as System.IComparable[of A] = null
z as object = null

assert 0== a.CompareTo(a)
assert 0== a.CompareTo(b)
assert 0== a.CompareTo(c)
assert 0== a.CompareTo(d)
#assert 0== a.CompareTo(e) # Raises exception as it should
#assert 0== a.CompareTo(f) # Raises exception as it should
assert 0!= a.CompareTo(w)
assert 0!= a.CompareTo(x)
#assert 0!= a.CompareTo(y) # BOO-1061
assert 0!= a.CompareTo(z)
assert 0!= a.CompareTo(null)

assert 0== b.CompareTo(a)
assert 0== b.CompareTo(b)
assert 0== b.CompareTo(c)
assert 0== b.CompareTo(d)
#assert 0== b.CompareTo(e) # Raises exception as it should
#assert 0== b.CompareTo(f) # Raises exception as it should
assert 0!= b.CompareTo(w)
assert 0!= b.CompareTo(x)
assert 0!= b.CompareTo(y)
assert 0!= b.CompareTo(z)
assert 0!= b.CompareTo(null)

assert 0== c.CompareTo(a)
assert 0== c.CompareTo(b)
assert 0== c.CompareTo(c)
assert 0== c.CompareTo(d)
#assert 0== c.CompareTo(e)
#assert 0== c.CompareTo(f) # Attempts to cast from object to A, but fails
#assert 0!= c.CompareTo(w)
#assert 0!= c.CompareTo(x) # BOO-1061
#assert 0!= c.CompareTo(y) # BOO-1061
#assert 0!= c.CompareTo(z) # BOO-1061
#assert 0!= c.CompareTo(null)

assert not a < a
assert not a < e
assert not a < w
assert not a < null
assert     a <= a
assert     a <= e
assert not a <= w
assert not a <= null
assert not a > a
assert not a > e
assert     a > w
assert     a > null
assert     a >= a
assert     a >= e
assert     a >= w
assert     a >= null

assert not e < a
#assert not e < e
#assert not e < w
#assert not e < null
assert     e <= a
#assert     e <= e
#assert not e <= w
#assert not e <= null
assert not e > a
#assert not e > e
#assert     e > w
#assert     e > null
assert     e >= a
#assert     e >= e
#assert     e >= w
#assert     e >= null

assert     w < a
#assert     w < e
#assert not w < w
#assert not w < null
assert     w <= a
#assert     w <= e
#assert     w <= w
#assert     w <= null
assert not w > a
#assert not w > e
#assert not w > w
#assert not w > null
assert not w >= a
#assert not w >= e
#assert     w >= w
#assert     w >= null

assert     null < a
#assert     null < e
#assert not null < w
assert     null <= a
#assert     null <= e
#assert     null <= w
assert not null > a
#assert not null > e
#assert not null > w
assert not null >= a
#assert not null >= e
#assert     null >= w
